﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using SimhoppKjellsFavoriterVT13;

namespace Kjellsfavoriter_TEST
{
    [TestFixture]
    class Jump_test
    {
        Jump testJump1;
        Jump testJump2;
        Jump testJump3;
        Jump testJump4;
        Jump testJump5;
        Jump testJump6;


        private void initializeJudges(Jump jump, float total)
        {
            for (int i = 0; i < 7; i++)
            {
                Judge j = new Judge();
                j.Total = total;
                jump.Judges.Add(j);
            }
        }

        [SetUp]
        protected void SetUp()
        {
            testJump1 = new Jump();
            testJump2 = new Jump();
            testJump3 = new Jump();
            testJump4 = new Jump();
            testJump5 = new Jump();
            testJump6 = new Jump();


            initializeJudges(testJump1, 1);
            initializeJudges(testJump2, 3);
            initializeJudges(testJump3, -2);
            initializeJudges(testJump4, 11);
            initializeJudges(testJump5, 0);
            initializeJudges(testJump6, 5);


        }


        [Test]
        public void TestTotalPoints()
        {
            testJump1.totalPoints = testJump1.calculateTotalPoints();
            testJump2.totalPoints = testJump2.calculateTotalPoints();
            testJump3.totalPoints = testJump3.calculateTotalPoints();
            testJump4.totalPoints = testJump4.calculateTotalPoints();
            testJump5.totalPoints = testJump5.calculateTotalPoints();
            testJump6.totalPoints = testJump6.calculateTotalPoints();


            Assert.AreEqual(5, testJump1.totalPoints);
            Assert.AreEqual(15, testJump2.totalPoints);
            Assert.AreEqual(-1, testJump3.totalPoints);
            Assert.AreEqual(-1, testJump4.totalPoints);
            Assert.AreEqual(0, testJump5.totalPoints);
            Assert.AreEqual(25, testJump6.totalPoints);
        }

        [Test]
        public void testPointsJudge()
        {
            testJudgePerJump(testJump1, 1);
            testJudgePerJump(testJump2, 3);
            testJudgePerJump(testJump3, -1);
            testJudgePerJump(testJump4, -1);
            testJudgePerJump(testJump5, 0);
            testJudgePerJump(testJump6, 5);
        }

        public void testJudgePerJump(Jump j, float correctPoint)
        {
            for (int i = 1; i < 8; i++)
            {                
                Assert.AreEqual(correctPoint, j.calculatePointsForJudge(i));
            }
        }

    }
}
